package com.pgeneral.user.management.controller;/**
 * @author 龙
 * @create 2020/7/2 14:30
 */

import com.pgeneral.user.management.config.ResultBean;
import com.pgeneral.user.management.entity.SopRoleScope;
import com.pgeneral.user.management.entity.SopRoleScope;
import com.pgeneral.user.management.service.impl.SopRoleScopeServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *@ClassName SopRoleScopeController
 *@Description 角色权限关联的增删改查接口
 *@Author JL
 *@Date 2020/7/2 14:30
 *@version 1.0
 **/

@Slf4j
@RestController
@RequestMapping("/sopRoleScope")
public class SopRoleScopeController {

    @Autowired
    private SopRoleScopeServiceImpl sopRoleScopeService;

    /**
     * 添加角色权限关系
     *
     * @param sopRoleScopes
     * @return
     */
    @RequestMapping(value = "/saveInfo", method = RequestMethod.POST)
    public ResultBean insertSopRoleScopeTable(@RequestBody List<SopRoleScope> sopRoleScopes) {
        log.info("调用角色权限关系save方法，方法参数为：{}",sopRoleScopes);
        int result = sopRoleScopeService.insert(sopRoleScopes);
        return ResultBean.InsertSuccessResult(result);

    }

    /**
     * 角色权限关系查询
     *
     * @param sopRoleScope
     * @return
     */
    @RequestMapping(value = "/getInfo", method = RequestMethod.POST)
    public ResultBean getSopRoleScopeTable(@RequestBody SopRoleScope sopRoleScope) {
        log.info("调用角色权限关系get方法，方法参数为：{}",sopRoleScope);
        List<SopRoleScope> sopRoleScopes = sopRoleScopeService.getSopRoleScopeTable(sopRoleScope);
        return ResultBean.Success(sopRoleScopes);

    }

    /**
     * 角色权限关系更新
     *
     * @param sopRoleScopes
     * @return
     */
    @RequestMapping(value = "/updateInfo", method = RequestMethod.POST)
    public ResultBean updateSopRoleScopeTable(@RequestBody List<SopRoleScope> sopRoleScopes) {
        log.info("调用角色权限关系update方法，方法参数为：{}",sopRoleScopes);
        int result = sopRoleScopeService.updateSopRoleScopeTable(sopRoleScopes);
        return ResultBean.InsertSuccessResult(result);

    }

    /**
     * 角色权限关系删除
     *
     * @param ids
     * @return
     */
    @RequestMapping(value = "/deleteInfo", method = RequestMethod.POST)
    public ResultBean deleteSopRoleScopeTable(@RequestBody List<String> ids) {
        log.info("调用角色权限关系delete方法，方法参数为：{}",ids);
        int result = sopRoleScopeService.updateIsDeletefromSopRoleScopeTable(ids);
        return ResultBean.InsertSuccessResult(result);
    }
}
